package com.sh.令牌桶算法;

public class TokenBucketLimiterTest {
    public static void main(String[] args) throws InterruptedException {
        TokenBucketLimiter limiter = new TokenBucketLimiter(100, 5);

        // 模拟多次请求
        for (int i = 0; i < 200; i++) {
            Thread.sleep(100);
            boolean allowed = limiter.limit();
            if (allowed) {
                System.out.println("请求 " + i + " 被允许。");
            } else {
                System.out.println("请求 " + i + " 被拒绝。");
            }
        }
    }
}